package persistent.impl;

import java.util.List;

import basic.HibBaseDAO;
import model.TCheckType;
import persistent.dao.ICheckTypeDAO;

public class CheckTypeDAOImpl implements ICheckTypeDAO {
	HibBaseDAO dao = new HibBaseDAO();
	
	@Override
	public List<TCheckType> getAllCheckType() {
		String hql = "from TCheckType";
		return dao.select(hql);
	}

	@Override
	public TCheckType getCheckTypeByName(String name) {
		String hql = "from TCheckType where checkname = ?";
		Object[] para = {name.trim()};
		List list = dao.select(hql, para);
		if(list!=null){
			return (TCheckType)list.get(0);
		}else{
			return null;
		}
	}

	@Override
	public TCheckType getCheckTypeById(int id){
		return (TCheckType)dao.findById(TCheckType.class, id);
	}

	public static void main(String args[]){
		TCheckType ct= new CheckTypeDAOImpl().getCheckTypeById(2);
		System.out.println(ct.getCheckname());
	}
}
